package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.bean.CustomerBean;
import com.zzj.service.CustomerService;
import com.zzj.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api
//@CrossOrigin
@RequestMapping("customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @GetMapping("findAll")
    @ApiOperation("查询所有客户")
    public PageInfo<CustomerBean> findAll(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "5") int pageSize
    ){
        return customerService.findAll(pageNum,pageSize);
    }

    @PutMapping("updateCustomer")
    @ApiOperation("修改客户")
    public Result updateCustomer(@RequestBody CustomerBean customerBean){
        System.out.println("customerBean = " + customerBean);
        return customerService.updateCustomer(customerBean);
    }
}
